import { post } from "@/request/http";
import { get } from "@/request/http";
import store from "@/store";


//查询所有糖厂需求
export const checkAllSugarDmand = ({
  site,
  destination,
  demandCode,
  status,
  PageIndex,
  PageSize,
  submitStartTime,
  submitEndTime
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/queryDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            fltUuid: store.state.user.FLT_UUID_DX_H,
            sugarDptId: store.state.user.DPTID_DX_H,
            demandCode,
            status,
            site,
            destination,
            submitStartTime,
            submitEndTime
          }
        },
        Orderby: {},
        PageIndex: {
          FTKJWLHYPT: PageIndex
        },
        PageSize: {
          FTKJWLHYPT: PageSize
        }
      }
    }
  )
//查询糖厂线路信息
export const quertLineInfo = ({
  sugarId
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/queryLineInfo',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            sugarId: sugarId
          }
        }
      }
    }
  )
//查询糖厂历史线路信息
export const queryLineInfoHistory = ({
  sugarId
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/queryLineInfoHistory',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            sugarId: sugarId
          }
        }
      }
    }
  )
//查询所有糖厂需求
export const getRefCodes = ({ transportMode }) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/queryDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            rvDomain: transportMode,
          }
        }
      }
    }
  )
//查询所有糖厂需求
export const queryAllSfdoService = ({ sfdoSdfDemandCode }) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/queryAllSfdo',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            sfdoSdfDemandCode: sfdoSdfDemandCode,
          }
        }
      }
    }
  )
//删除线路信息
export const delLineInfo = ({
  lineId
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/delLineInfo',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            lineId: lineId,
          }
        }
      }
    }
  )
//  新增
export const addDmandService = (data) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/addDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            creator: store.state.user.USR_CODE_DX_H,
            // pdtLstmodifier: store.state.user.USR_CODE_DX_H,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            sugarDptId: store.state.user.DPTID_DX_H,
            demandCode: data.demandCode, // 需求编号
            kind: data.kind, // 品种
            kindName: data.kindName, // 品名
            transportType: data.transportType, // 运输类型
            transportMode: data.transportMode, // 运输方式
            dailyOutput: data.dailyOutput, // 日产量 后改为 规格
            transportQuantity: data.transportQuantity, // 榨季期间运输数量 后改为 货物的运输数量
            settlementWay: data.settlementWay, //结算方式
            specialRequire: data.specialRequires, //特殊需求
            performanceBond: data.performanceBond, //履约保证金

            goodCode: data.goodCode, //货物编码
            projuctBig: data.projuctBig, //产品大类
            goodBrand: data.goodBrand, //货物品牌

            contractDeposit: data.contractDeposit, // 合同定金
            requiredStartTime: data.requiredStartTime, // 要求开始时间
            requiredEndTime: data.requiredEndTime, // 要求完成时间
            requiredEndDay: data.requiredEndDay, // 要求完成天数
            remark: data.remark, // 备注
            demandLineInfos: data.demandLineInfos //线路信息
          }
        }
      }
    }
  )
//  编辑
export const editDmandService = (data) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/editDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            editor: store.state.user.USR_CODE_DX_H,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            sugarDptId: store.state.user.DPTID_DX_H,
            sugarId: data.sugarId, //需求id
            demandCode: data.demandCode, // 需求编号
            kind: data.kind, // 品种
            kindName: data.kindName, // 品名
            transportType: data.transportType, // 运输类型
            transportMode: data.transportMode, // 运输方式
            dailyOutput: data.dailyOutput, // 日产量
            transportQuantity: data.transportQuantity, // 榨季期间运输数量
            settlementWay: data.settlementWay, //结算方式
            specialRequire: data.specialRequires, //特殊需求
            performanceBond: data.performanceBond, //履约保证金

            goodCode: data.goodCode, //货物编码
            projuctBig: data.projuctBig, //产品大类
            goodBrand: data.goodBrand, //货物品牌

            contractDeposit: data.contractDeposit, // 合同定金
            requiredStartTime: data.requiredStartTime, // 要求开始时间
            requiredEndTime: data.requiredEndTime, // 要求完成时间
            requiredEndDay: data.requiredEndDay, // 要求完成天数
            remark: data.remark, // 备注
            isEdit: data.isEdit, //平台是否修改
            demandLineInfos: data.demandLineInfos //线路信息
          }
        }
      }
    }
  )
//删除需求
export const delDmandService = ({
  sugarId
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/delDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            sugarId: sugarId,
            editor: store.state.user.USR_CODE_DX_H,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            sugarDptId: store.state.user.DPTID_DX_H,
          }
        }
      }
    }
  )
//发布需求
export const releaseDmandService = ({
  sugarId, status
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/releaseDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            sugarId: sugarId,
            status: status,
            editor: store.state.user.USR_CODE_DX_H,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            sugarDptId: store.state.user.DPTID_DX_H,
          }
        }
      }
    }
  )
//提交平台
export const submitDmandService = ({
  sugarId
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/releaseDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            sugarId: sugarId,
            status: 'YTJ',
            editor: store.state.user.USR_CODE_DX_H,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            sugarDptId: store.state.user.DPTID_DX_H,
          }
        }
      }
    }
  )
//取消发布需求
export const unReleaseDmandService = ({
  sugarId
}) =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/unReleaseDemand',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            sugarId: sugarId,
            editor: store.state.user.USR_CODE_DX_H,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            sugarDptId: store.state.user.DPTID_DX_H,
          }
        }
      }
    }
  )
//生成需求编号
export const generateRequirementNumberService = () =>
  post(
    '/FTKJWLHYPT/sugarFactoryDemand/generateRequirementNumber',
    {
      fltUuid: store.state.user.FLT_UUID_DX_H
    }
  )
//生成货物编号
export const generategoodsNumberService = ({
  kind
}) =>
  get(
    '/FTKJWLHYPT/sugarFactoryDemand/generategoodsNumber',
    {
      kind
    }
  )
